package ar.edu.itba.it.cg.grupo01.impl.parser;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import ar.edu.itba.it.cg.grupo01.api.shape.Shape;
import ar.edu.itba.it.cg.grupo01.api.shape.light.Light;
import ar.edu.itba.it.cg.grupo01.impl.CameraBuilder;
import ar.edu.itba.it.cg.grupo01.impl.shape.Plane;
import ar.edu.itba.it.cg.grupo01.impl.shape.light.PointLight;
import ar.edu.itba.it.cg.grupo01.impl.shape.shader.Shader;

public class SceneDTO {

	private CameraBuilder camera;
	private List<Shape> scene = new ArrayList<Shape>();
	private List<Light> lights = new ArrayList<Light>();
	private List<Plane> planes = new ArrayList<Plane>();
	private HashMap<String,Shader> shaders = new HashMap<String, Shader>();
	private int antiAliasing = 0;
	
	
	public int getAntiAliasing() {
		return antiAliasing;
	}

	public void setAntiAliasing(int antiAliasing) {
		this.antiAliasing = antiAliasing;
	}

	public void addShader(String name, Shader aShader){
		this.shaders.put(name, aShader);
	}
	
	public boolean shaderIsAlreadyInserted(String name){
		return (this.shaders.get(name) != null);
	}
	
	public void build()
	{
		
		List<Shape> sceneTransformed = new ArrayList<Shape>();
		List<Plane> planesTransformed = new ArrayList<Plane>();
		
		for (Shape shape : scene) {
			sceneTransformed.add(shape.applyTransformation());
		}
		for (Plane plane : planes) {
			planesTransformed.add((Plane)plane.applyTransformation());
		}
		
		scene = sceneTransformed;
		planes = planesTransformed;
	}
	public HashMap<String, Shader> getShaders() {
		return shaders;
	}

	public void setShaders(HashMap<String, Shader> shaders) {
		this.shaders = shaders;
	}

	public void addPlane(Plane aPlane)
	{
		planes.add(aPlane);
	}
	
	public List<Plane> getPlanes() {
		return planes;
	}

	public void setPlanes(List<Plane> planes) {
		this.planes = planes;
	}

	public void addLight(PointLight aLight)
	{
		lights.add(aLight);
	}
	
	public List<Light> getLights() {
		return lights;
	}

	public void setLights(List<Light> lights) {
		this.lights = lights;
	}

	public List<Shape> getScene() {
		return scene;
	}

	public void setScene(List<Shape> scene) {
		this.scene = scene;
	}

	public void addShape(Shape aShape){
		scene.add(aShape);
	}
	
	public CameraBuilder getCamera() {
		return camera;
	}

	public void setCamera(CameraBuilder camera) {
		this.camera = camera;
	}
	
}












